package edu.sctu.practice.class01.zhangwang.day2015_10_14.text01;

/**
 * Created by Z_W on 2015/10/15.
 */
public class Sleep implements Runnable{

    @Override
    public void run() {
        System.out.println("执行run方法。");
        try {
            Thread.sleep(10000);
            System.out.println("正常休眠。");
        } catch (InterruptedException e) {
            System.out.println("休眠被终止。");
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Sleep sleep = new Sleep();
        Thread thread = new Thread(sleep,"线程");

        thread.start();

            try {
                Thread.sleep(2000);

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            thread.interrupt();
    }
}
